<template>
  <el-checkbox-group v-model="checkList" v-bind="$attrs" v-on="$listeners">
    <el-checkbox v-for="item in options"
      :key="item.label"
      :disabled="item.disabled"
      :label="item.value">
      {{ item.label }}
    </el-checkbox>
  </el-checkbox-group>
</template>

<script>
  export default {
    name: 'Checkbox',
    props: {
      options: {
        type: Array,
        default: () => []
      },
      // 绑定id数组
      value: {
        type: Array,
        default: () => []
      }
    },
    data () {
      return {
        checkList: []
      }
    },
    mounted () {

    },
    watch: {
      value: {
        handler (newV) {
          this.checkList = newV.map(item => {
            return this.options.find(option => option.value === item).value
          })
        }
      }
    }
  }
</script>

<style scoped>
</style>
